{capture assign='pnm'}{$product->name()} {$product->model()}{/capture}

{include file='gallery.tpl' images=$allImages}

<div class="breadcrumbs">
	<ul>
		<li><a href="/catalog">Каталог</a> / </li>
		{foreach $crumbs as $crumb}
			{if $crumb@index==0}
				<li><a href="/catalog/{$crumb.code}">{$crumb.name}</a> / </li>
			{else}
				<li><a href="/catalog/{$crumbs[0].code}#{$crumb.code}">{$crumb.name}</a> / </li>
			{/if}
		{/foreach}
		<li>{$pnm}</li>
	</ul>
</div>

<div class="section">
	<h2>{$pnm}</h2>
	
	<div class='product-images'>
		<div class="img-holder">
			<a href="#" onclick="showGallery(0);return false;">
				<img src='{thumbnail width=430 height=300}{$product->image()}{/thumbnail}' title="{$product->imageText()|default:$pnm}" alt="{$product->imageText()|default:$pnm}"/>
			</a>
			{if $discount}
				<img class='discount' src="/images/{$discount}.png"/>
			{/if}
		</div>
		<ul class="img-list">
			{section loop=$images name=img start=1}
				<a href="#" onclick="showGallery({$smarty.section.img.index});return false;">
					<li><img src="{thumbnail width=110 height=125}{$images[img]}{/thumbnail}" title="{$imageTexts[img]|default:$pnm}" alt="{$imageTexts[img]|default:$pnm}" /></li>
				</a>
			{/section}
		</ul>
	</div>
	
	<div class="text-holder">
		{foreach $attributes as $attribute}
			<dl>
				<dt>{$attribute->name()}:</dt>
				<dd>{$attribute->value()}</dd>
			</dl>
		{/foreach}
		{if $product->price() != 0}
			<dl>
				<dt>Цена:</dt>
				<dd>
					<a href='/prices'>{price cents=0}{$product->price()}{/price} рублей</a>
				</dd>
			</dl>
		{/if}
	</div>
</div>

{if !$options->is_empty()}
<table id='product_options' class='with_divider' width=100%>
{foreach $options as $option}
	{$opAttributes = $optionAttributes[$option@index]}
	{$opImage = $optionImages[$option@index]}
	<tr>
		<td>
			{if $opImage}
				<a class='image' href=# onclick="showGallery({$images|count+$option@index});return false;">
					<img src="{thumbnail width=110 height=125}{$opImage}{/thumbnail}" /> 
				</a>
			{/if}
		</td>
		<td>
			{$opAttributes->get('articul')}
		</td> 
		<td width=100%>
			{$option->name()}
		</td>
		<td>
			{$opAttributes->get('complect')}
		</td>
		<td>
			{$opAttributes->get('size')}
		</td>
		<td>
			{$opAttributes->get('color')}
		</td>
		<td>
			{$opAttributes->get('material')}
		</td>
		<td>
			{$opAttributes->get('electric')}
		</td>
		<td>
			{$opAttributes->get('safety')}
		</td>
		<td class='price' style="white-space:nowrap;">
			<a href='/prices' style="">{price cents=0}{$option->price()}{/price} рублей</a>
		</td>
	</tr>
{/foreach}
</table>
{/if}

{if $product->fullDescr()|count_characters}
<div class='product-descr with_divider'>
	{$product->fullDescr()}
</div>
{/if}

<script>
	$(function(){
		$('.product-descr .discount').each(function(){
			var p = $(this).parent();
			p.remove();
			$('.section .text-holder').append('<br>').append(p);
		});
	})
</script>